<?php

/**
 * This is the model class for table "{{mail}}".
 *
 * The followings are the available columns in table '{{mail}}':
 * @property integer $mail_id
 * @property string $mail_name
 * @property string $mail_subject
 * @property string $mail_body
 * @property integer $mail_created
 * @property integer $mail_reply
 * @property integer $mail_ip
 * @property string $mail_email
 */
class Email extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Mail the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{mail}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('mail_name, mail_subject, mail_body, mail_email', 'required'),
			array('mail_created, mail_reply, mail_ip', 'numerical', 'integerOnly'=>true),
			array('mail_name, mail_email', 'length', 'max'=>100),
			array('mail_subject', 'length', 'max'=>200),
			
			// email has to be a valid email address
			array('mail_email', 'email'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('mail_id, mail_name, mail_subject, mail_body, mail_created, mail_reply, mail_ip, mail_email', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'mail_id' => 'Mail',
			'mail_name' => 'Mail Name',
			'mail_subject' => 'Mail Subject',
			'mail_body' => 'Mail Body',
			'mail_created' => 'Mail Created',
			'mail_reply' => 'Mail Reply',
			'mail_ip' => 'Mail Ip',
			'mail_email' => 'Mail Email',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('mail_id',$this->mail_id);
		$criteria->compare('mail_name',$this->mail_name,true);
		$criteria->compare('mail_subject',$this->mail_subject,true);
		$criteria->compare('mail_body',$this->mail_body,true);
		$criteria->compare('mail_created',$this->mail_created);
		$criteria->compare('mail_reply',$this->mail_reply);
		$criteria->compare('mail_ip',$this->mail_ip);
		$criteria->compare('mail_email',$this->mail_email,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}